#pragma once
#include<string>

const std::string opers="+-*/%";
enum
{
    Divzero=1,
    Modzero=2,
    Unknow
};

class Task
{
public:
    Task()
    {}
    Task(int x,int y,char op)
        :data1(x),data2(y),oper(op),result(0),exitcode(0)
    {}

    void run()
    {
        switch(oper)
        {
            case '+':
                result=data1+data2;
                break;
            case '-':
                result=data1-data2;
                break;
            case '*':
                result=data1*data2;
                break;
            case '/':
                if(data2==0)
                    exitcode=Divzero;
                else
                    result=data1/data2;                
                break;

            case '%':
                if(data2==0)
                    exitcode=Modzero;
                else
                    result=data1%data2;
                break;
            default:
                exitcode=Unknow;
                break;
        }
    }

    bool operator()()
    {
        run();
        return true;
    }

    std::string GetResult()
    {
        std::string r=std::to_string(data1);
        r+=oper;
        r+=std::to_string(data2);
        r+='=';
        r+=std::to_string(result);
        r+="[code:";
        r+=std::to_string(exitcode);
        return r;
    }

    std::string GetTask()
    {
        
        std::string r=std::to_string(data1);
        r+=oper;
        r+=std::to_string(data2);
        r+="= ?";
        return r; 
    }
    
    ~Task()
    {}
private:
    int data1;
    int data2;
    char oper;

    int result;
    int exitcode;
};